<?php
class DB{

	public static $db;

	public static function init($dbtype, $config){
		self::$db = new $dbtype;
		self::$db -> connect($config);
	}

	public static function query($sql){
		return self::$db->query($sql);
	}

	public static function findAll($sql){
		$query = self::$db->query($sql);
		return self::$db->findAll($query);
	}

	//查询一条数据
	public static function findOne($sql){
		$query = self::$db->query($sql);
		return self::$db->findOne($query);
	}

	//查询一组数据
	public static function findResult($sql, $row = 0, $filed = 0){
		$query = self::$db->query($sql);
		return self::$db->findResult($query, $row, $filed);
	}

	//查找数据
	public static function insert($table, $arr){
		return self::$db->insert($table, $arr);
	}

	//修改数据
	public static function update($table, $arr, $where){
		return self::$db->update($table, $arr, $where);
	}

	//删除数据
	public static function del($table, $where){
		return self::$db->del($table, $where);
	}
}

?>